<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>疫情防控系统</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
</head>
<body class="hold-transition dark-mode sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
<div class="wrapper">

  <!-- Preloader -->
  <div class="preloader flex-column justify-content-center align-items-center">
    <img class="animation__wobble" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
  </div>

  <!-- todo Navbar 主界面左上角 -->
  <nav class="main-header navbar navbar-expand navbar-dark">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <div class="dropdown">
          <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
            切换摄像头
            <span class="caret"></span>
          </button>
          <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
            <li><button class="btn btn-default">127.0.0.1</button></li>
            <li><button class="btn btn-default">127.0.0.2</button></li>
            <li><button class="btn btn-default">127.0.0.3</button></li>
          </ul>
        </div>
      </li>
    </ul>

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- Navbar Search -->
      <li class="nav-item">
        <a class="nav-link" data-widget="navbar-search" href="#" role="button">
          <i class="fas fa-search"></i>
        </a>
        <div class="navbar-search-block">
          <form class="form-inline">
            <div class="input-group input-group-sm">
              <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
              <div class="input-group-append">
                <button class="btn btn-navbar" type="submit">
                  <i class="fas fa-search"></i>
                </button>
                <button class="btn btn-navbar" type="button" data-widget="navbar-search">
                  <i class="fas fa-times"></i>
                </button>
              </div>
            </div>
          </form>
        </div>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-widget="fullscreen" href="#" role="button">
          <i class="fas fa-expand-arrows-alt"></i>
        </a>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="index3.html" class="brand-link">
      <img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
      <span class="brand-text font-weight-light">疫情防控系统</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      <div class="user-panel mt-3 pb-3 mb-3 d-flex">
        <!--<div class="image">
          <img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
        </div>-->
        <div class="info">
          <span class="nav-icon fa fa-user"> admin</span>
        </div>
      </div>


      <!-- todo Sidebar Menu 左边菜单栏 -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
          <li class="nav-item">
            <a href="javascript:" class="nav-link">
              <i class="nav-icon fa fa-camera"></i>
              <p>
                摄像头管理
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="javascript:change_to_result_content();" class="nav-link">
              <i class="nav-icon fa fa-film"></i>
              <p>
                实时检测结果查看
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <i class="nav-icon fas fa-chart-pie"></i>
              <p>
                下拉 demo
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="pages/charts/chartjs.html" class="nav-link">
                  <i class="far fa-circle nav-icon"></i>
                  <p>ChartJS</p>
                </a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- todo Main content 主界面内容 -->
    <section class="content">
      <div id="my_main_container" class="container-fluid">
          <div class="row">
              <div class="col-md-12">
                  <div id="interactive" style="height: 600px;"></div>
              </div>
              <!-- /.col -->
          </div>
          <!-- /.row -->
          <hr>
          <div class="row">
              <div class="col-md-6">
                  <div id="zhuzhuangtu" style="height: 600px;"></div>
              </div>
              <!-- /.col -->
              <div class="col-md-6">
                  <div id="meiguitu" style="height: 600px;"></div>
              </div>
              <!-- /.col -->
          </div>
          <!-- /.row -->
          <hr>
      </div><!--/. container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <strong>Copyright &copy; 2014-2021 <a href="https://adminlte.io">AdminLTE.io</a>.</strong>
    All rights reserved.
    <div class="float-right d-none d-sm-inline-block">
      <b>Version</b> 3.2.0
    </div>
  </footer>
</div>
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>

<!-- PAGE PLUGINS -->
<!-- jQuery Mapael -->
<script src="plugins/jquery-mousewheel/jquery.mousewheel.js"></script>
<script src="plugins/raphael/raphael.min.js"></script>
<script src="plugins/jquery-mapael/jquery.mapael.min.js"></script>
<script src="plugins/jquery-mapael/maps/usa_states.min.js"></script>
<!-- eChartsJS -->
<script src="/static/js/echarts.js"></script>

<script>
    // real_time = 1: 打开实时刷新数据
    var real_time = 0

    $(document).ready(function(){
        // todo 定时刷新堆叠曲线图
        var chartDom = document.getElementById('interactive');
        var myChart = echarts.init(chartDom, 'dark');
        var option;
        var updateInterval = 500;

        option = {
          title: {
            text: 'mask count'
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'cross',
              label: {
                backgroundColor: '#6a7985'
              }
            }
          },
          legend: {
            data: ['mask', 'no mask', 'all']
          },
          toolbox: {
            feature: {
              saveAsImage: {}
            }
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          xAxis: [
            {
              type: 'category',
              boundaryGap: false,
              data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
            }
          ],
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [
            {
              name: 'mask',
              type: 'line',
              stack: 'Total',
              areaStyle: {},
              emphasis: {
                focus: 'series'
              },
              data: [120, 132, 101, 134, 90, 230, 210, 90, 230, 210]
            },
            {
              name: 'no mask',
              type: 'line',
              stack: 'Total',
              areaStyle: {},
              emphasis: {
                focus: 'series'
              },
              data: [220, 182, 191, 234, 290, 330, 310, 90, 230, 210]
            },
            {
              name: 'all',
              type: 'line',
              stack: 'Total',
              areaStyle: {},
              emphasis: {
                focus: 'series'
              },
              data: [150, 232, 201, 154, 190, 330, 410, 90, 230, 210]
            },
          ]
        };

        // 请求后端得到mask、no mask、 all的数据
        function update() {
            $.get(
                "/group_of_people/get_data?type=interactive",
                function (data, state) {
                    // console.log(data);
                    option.series = data.series;
                    option && myChart.setOption(option);
                    setTimeout(update, updateInterval)
                }
            );
        }
        option && myChart.setOption(option);
        if(real_time == 1){update();}

        // todo 定时刷新柱状图
        var chartDom_zhuzhuangtu = document.getElementById('zhuzhuangtu');
        var myChart_zhuzhuangtu = echarts.init(chartDom_zhuzhuangtu, 'dark');
        var option_zhuzhuangtu;
        option_zhuzhuangtu = {
          xAxis: {
            type: 'category',
            data: ['mask', 'no mask', 'all']
          },
          yAxis: {
            type: 'value'
          },
          series: [
            {
              data: [
                {
                  value: 120,
                  itemStyle: {
                    color: '#12ED93'
                  }
                },
                {
                  value: 80,
                  itemStyle: {
                    color: '#3F77FE'
                  }
                },
                {
                  value: 200,
                  itemStyle: {
                    color: '#d223e7'
                  }
                }
              ],
              type: 'bar'
            }
          ]
        };
        function update_zhuzhuangtu() {
            $.get(
                "/group_of_people/get_data?type=zhuzhuangtu",
                function (data, state) {
                    // console.log(data);
                    option_zhuzhuangtu.series = [
                        {
                          data: data.data,
                          type: 'bar'
                        }
                    ]
                    // console.log(option_zhuzhuangtu);
                    option_zhuzhuangtu && myChart_zhuzhuangtu.setOption(option_zhuzhuangtu);
                    setTimeout(update_zhuzhuangtu, updateInterval)
                }
            );
        }
        option_zhuzhuangtu && myChart_zhuzhuangtu.setOption(option_zhuzhuangtu);
        if(real_time == 1){update_zhuzhuangtu();}

        // todo 玫瑰图
        var chartDom_meiguitu = document.getElementById('meiguitu');
        var myChart_meiguitu = echarts.init(chartDom_meiguitu, 'dark');
        var option_meiguitu;

        option_meiguitu = {
          legend: {
            top: 'bottom'
          },
          toolbox: {
            show: true,
            feature: {
              mark: { show: true },
              dataView: { show: true, readOnly: false },
              restore: { show: true },
              saveAsImage: { show: true }
            }
          },
          series: [
            {
              name: 'Nightingale Chart',
              type: 'pie',
              radius: [50, 250],
              center: ['50%', '50%'],
              roseType: 'area',
              itemStyle: {
                borderRadius: 8
              },
              data: [
                { value: 40, name: 'rose 1' },
                { value: 38, name: 'rose 2' },
                { value: 32, name: 'rose 3' }
              ]
            }
          ]
        };
        function update_meiguitu() {
            $.get(
                "/group_of_people/get_data?type=meiguitu",
                function (data, state) {
                    // console.log(data);
                    option_meiguitu.series[0].data = data.data;
                    option_meiguitu && myChart_meiguitu.setOption(option_meiguitu);
                    setTimeout(update_meiguitu, updateInterval)
                }
            );
        }
        option_meiguitu && myChart_meiguitu.setOption(option_meiguitu);
        if(real_time == 1){update_meiguitu();}
    });
</script>
</body>
</html>
